using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VQOSTEP
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                case "TST":
                default:
                    #region=========
                    dwReturn["QOEMANDANT"] = app.Mandant;
                    dwReturn["QOEORDER"] = "000000000";
                    dwReturn["QOESTEP"] = "0000";
                    dwReturn["QOENEUB"] = "        ";
                    dwReturn["QOENEUD"] = "0";
                    dwReturn["QOEAENB"] = "        ";
                    dwReturn["QOEAEND"] = "0";
                    dwReturn["QOEAENZL"] = "0";
                    dwReturn["QOEPNRKRS"] = "  ";
                    dwReturn["QOEPLFDNR"] = "000000";
                    dwReturn["QOEPSTEP"] = "0000";
                    dwReturn["QOEMERKM"] = "WG  ";
                    dwReturn["QOEVERS"] = "00";
                    dwReturn["QOENUMKZ"] = "N";
                    dwReturn["QOEMEEH"] = "   ";
                    dwReturn["QOEPMGRP"] = "        ";
                    dwReturn["QOEPGROE"] = "PP";
                    dwReturn["QOEPGRKZ"] = "PP";
                    dwReturn["QOEANZPR"] = "1";
                    dwReturn["QOEPBENID"] = "        ";
                    dwReturn["QOEPDATUM"] = "0";
                    dwReturn["QOEMESSANZ"] = "10";
                    dwReturn["QOEPKSTKRS"] = "  ";
                    dwReturn["QOEPKST"] = "0000";
                    dwReturn["QOEPMLFD"] = "0";
                    dwReturn["QOESTATUS"] = "  ";
                    dwReturn["QOERESULT"] = " ";
                    dwReturn["QOEMRESULT"] = " ";
                    dwReturn["QOEERLDAT"] = "0";
                    dwReturn["QOEFRBENID"] = "        ";
                    dwReturn["QOEABBENID"] = "        ";
                    dwReturn["QOEABGRD"] = "  ";
                    dwReturn["QOERKSTKRS"] = "  ";
                    dwReturn["QOERKST"] = "0000";
                    dwReturn["QOEVERUR"] = "               ";
                    dwReturn["QOESKIPLOS"] = " ";
                    dwReturn["QOERORDER"] = "000000000";
                    dwReturn["QOERSTEP"] = "0000";
                    dwReturn["QOENSWERT"] = "0";
                    dwReturn["QOENSUG"] = "0";
                    dwReturn["QOENSOG"] = "0";
                    dwReturn["QOEASWERT"] = "0         ";
                    dwReturn["QOEASUG"] = "          ";
                    dwReturn["QOEASOG"] = "          ";
                    dwReturn["QOEANZIW"] = "1";
                    dwReturn["QOEMWERT"] = "0";
                    dwReturn["QOESTDABW"] = "0";
                    dwReturn["QOEMINWERT"] = "0";
                    dwReturn["QOEMAXWERT"] = "0";
                    dwReturn["QOENEUG"] = "0";
                    dwReturn["QOENEOG"] = "0";
                    dwReturn["QOETEXT1"] = "   ";
                    dwReturn["QOETEXT2"] = "   ";
                    dwReturn["QOEVKZ"] = " ";
                    dwReturn["QOEDRUCKKZ"] = "N";
                    dwReturn["QOEUGKZ"] = " ";
                    dwReturn["QOEOGKZ"] = " ";
                    dwReturn["QOECWEIGHT"] = "0";
                    dwReturn["QOEFPROCCOS"] = "0";
                    dwReturn["QOEFPROCCOR"] = "0";
                    dwReturn["QOEWE"] = "   ";
                    dwReturn["QOEKOMMENT"] = "                                        ";
                    dwReturn["QOEFILLER4"] = "          00  00000000  00000000                                                                         ";
                    #endregion
                    break;
            }
        }
        public void InsertQOSTEP(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "JLT":
                    or1.CommandText = "INSERT INTO QOSTEP ( QOEMANDANT,QOEORDER,QOESTEP,QOENEUB,QOENEUD,QOEAENB,QOEAEND,QOEAENZL,QOEPNRKRS,QOEPLFDNR,QOEPSTEP,QOEMERKM,QOEVERS,QOENUMKZ,QOEMEEH,QOEPMGRP,QOEPGROE,QOEPGRKZ,QOEANZPR,QOEPBENID,QOEPDATUM,QOEMESSANZ,QOEPKSTKRS,QOEPKST,QOEPMLFD,QOESTATUS,QOERESULT,QOEMRESULT,QOEERLDAT,QOEFRBENID,QOEABBENID,QOEABGRD,QOERKSTKRS,QOERKST,QOEVERUR,QOESKIPLOS,QOERORDER,QOERSTEP,QOENSWERT,QOENSUG,QOENSOG,QOEASWERT,QOEASUG,QOEASOG,QOEANZIW,QOEMWERT,QOESTDABW,QOEMINWERT,QOEMAXWERT,QOENEUG,QOENEOG,QOETEXT1,QOETEXT2,QOEVKZ,QOEDRUCKKZ,QOEUGKZ,QOEOGKZ,QOECWEIGHT,QOEFPROCCOS,QOEFPROCCOR,QOEWE,QOEKOMMENT,QOEFILLER4)"
                    + " VALUES (:QOEMANDANT:,:QOEORDER:,:QOESTEP:,:QOENEUB:,:QOENEUD:,:QOEAENB:,:QOEAEND:,:QOEAENZL:,:QOEPNRKRS:,:QOEPLFDNR:,:QOEPSTEP:,:QOEMERKM:,:QOEVERS:,:QOENUMKZ:,:QOEMEEH:,:QOEPMGRP:,:QOEPGROE:,:QOEPGRKZ:,:QOEANZPR:,:QOEPBENID:,:QOEPDATUM:,:QOEMESSANZ:,:QOEPKSTKRS:,:QOEPKST:,:QOEPMLFD:,:QOESTATUS:,:QOERESULT:,:QOEMRESULT:,:QOEERLDAT:,:QOEFRBENID:,:QOEABBENID:,:QOEABGRD:,:QOERKSTKRS:,:QOERKST:,:QOEVERUR:,:QOESKIPLOS:,:QOERORDER:,:QOERSTEP:,:QOENSWERT:,:QOENSUG:,:QOENSOG:,:QOEASWERT:,:QOEASUG:,:QOEASOG:,:QOEANZIW:,:QOEMWERT:,:QOESTDABW:,:QOEMINWERT:,:QOEMAXWERT:,:QOENEUG:,:QOENEOG:,:QOETEXT1:,:QOETEXT2:,:QOEVKZ:,:QOEDRUCKKZ:,:QOEUGKZ:,:QOEOGKZ:,:QOECWEIGHT:,:QOEFPROCCOS:,:QOEFPROCCOR:,:QOEWE:,:QOEKOMMENT:,:QOEFILLER4:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
                case "YGR":
                    or1.CommandText = "INSERT INTO QOSTEP ( QOEMANDANT,QOEORDER,QOESTEP,QOENEUB,QOENEUD,QOEAENB,QOEAEND,QOEAENZL,QOEPNRKRS,QOEPLFDNR,QOEPSTEP,QOEMERKM,QOEVERS,QOENUMKZ,QOEMEEH,QOEPMGRP,QOEPGROE,QOEPGRKZ,QOEANZPR,QOEPBENID,QOEPDATUM,QOEMESSANZ,QOEPKSTKRS,QOEPKST,QOEPMLFD,QOESTATUS,QOERESULT,QOEMRESULT,QOEERLDAT,QOEFRBENID,QOEABBENID,QOEABGRD,QOERKSTKRS,QOERKST,QOEVERUR,QOESKIPLOS,QOERORDER,QOERSTEP,QOENSWERT,QOENSUG,QOENSOG,QOEASWERT,QOEASUG,QOEASOG,QOEANZIW,QOEMWERT,QOESTDABW,QOEMINWERT,QOEMAXWERT,QOENEUG,QOENEOG,QOETEXT1,QOETEXT2,QOEVKZ,QOEDRUCKKZ,QOEUGKZ,QOEOGKZ,QOECWEIGHT,QOEFPROCCOS,QOEFPROCCOR,QOEWE,QOEKOMMENT,QOEFILLER4)"
                    + " VALUES (:QOEMANDANT:,:QOEORDER:,:QOESTEP:,:QOENEUB:,:QOENEUD:,:QOEAENB:,:QOEAEND:,:QOEAENZL:,:QOEPNRKRS:,:QOEPLFDNR:,:QOEPSTEP:,:QOEMERKM:,:QOEVERS:,:QOENUMKZ:,:QOEMEEH:,:QOEPMGRP:,:QOEPGROE:,:QOEPGRKZ:,:QOEANZPR:,:QOEPBENID:,:QOEPDATUM:,:QOEMESSANZ:,:QOEPKSTKRS:,:QOEPKST:,:QOEPMLFD:,:QOESTATUS:,:QOERESULT:,:QOEMRESULT:,:QOEERLDAT:,:QOEFRBENID:,:QOEABBENID:,:QOEABGRD:,:QOERKSTKRS:,:QOERKST:,:QOEVERUR:,:QOESKIPLOS:,:QOERORDER:,:QOERSTEP:,:QOENSWERT:,:QOENSUG:,:QOENSOG:,:QOEASWERT:,:QOEASUG:,:QOEASOG:,:QOEANZIW:,:QOEMWERT:,:QOESTDABW:,:QOEMINWERT:,:QOEMAXWERT:,:QOENEUG:,:QOENEOG:,:QOETEXT1:,:QOETEXT2:,:QOEVKZ:,:QOEDRUCKKZ:,:QOEUGKZ:,:QOEOGKZ:,:QOECWEIGHT:,:QOEFPROCCOS:,:QOEFPROCCOR:,:QOEWE:,:QOEKOMMENT:,:QOEFILLER4:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break; 
            }

            Connect2Proxy(or1);
        }
        public DataSet QueryQOSTEP(DataRow dwData, int option = 1)
        {

            DataSet Result ;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM QOSTEP WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT QPMBEZ,QPMNUMKZ,P.* FROM QOSTEP P JOIN QPMERKM M ON P.QOEMANDANT= M.QPMMANDANT AND P.QOEMERKM=M.QPMMERKM WHERE  QOEMANDANT=:QOEMANDANT: AND QOEORDER=:QOEORDER:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                 default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "QOSTEP";
            return Result;
        }
        public void DeleteQOSTEP(DataRow dwData, int option = 1)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM QOSTEP   WHERE QOEMANDANT=:QOEMANDANT: AND QOEORDER=:QOEORDER: AND QOESTEP=:QOESTEP: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
                case 2:
                    or1.CommandText = "DELETE FROM QOSTEP   WHERE QOEMANDANT=:QOEMANDANT: AND QOEORDER=:QOEORDER:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void UpdateQOSTEP(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0://JLT
                    or1.CommandText = "UPDATE QOSTEP SET QOEMANDANT=:QOEMANDANT:,QOEORDER=:QOEORDER:,QOESTEP=:QOESTEP:,QOENEUB=:QOENEUB:,QOENEUD=:QOENEUD:,QOEAENB=:QOEAENB:,QOEAEND=:QOEAEND:,QOEAENZL=:QOEAENZL:,QOEPNRKRS=:QOEPNRKRS:,QOEPLFDNR=:QOEPLFDNR:,QOEPSTEP=:QOEPSTEP:,QOEMERKM=:QOEMERKM:,QOEVERS=:QOEVERS:,QOENUMKZ=:QOENUMKZ:,QOEMEEH=:QOEMEEH:,QOEPMGRP=:QOEPMGRP:,QOEPGROE=:QOEPGROE:,QOEPGRKZ=:QOEPGRKZ:,QOEANZPR=:QOEANZPR:,QOEPBENID=:QOEPBENID:,QOEPDATUM=:QOEPDATUM:,QOEMESSANZ=:QOEMESSANZ:,QOEPKSTKRS=:QOEPKSTKRS:,QOEPKST=:QOEPKST:,QOEPMLFD=:QOEPMLFD:,QOESTATUS=:QOESTATUS:,QOERESULT=:QOERESULT:,QOEMRESULT=:QOEMRESULT:,QOEERLDAT=:QOEERLDAT:,QOEFRBENID=:QOEFRBENID:,QOEABBENID=:QOEABBENID:,QOEABGRD=:QOEABGRD:,QOERKSTKRS=:QOERKSTKRS:,QOERKST=:QOERKST:,QOEVERUR=:QOEVERUR:,QOESKIPLOS=:QOESKIPLOS:,QOERORDER=:QOERORDER:,QOERSTEP=:QOERSTEP:,QOENSWERT=:QOENSWERT:,QOENSUG=:QOENSUG:,QOENSOG=:QOENSOG:,QOEASWERT=:QOEASWERT:,QOEASUG=:QOEASUG:,QOEASOG=:QOEASOG:,QOEANZIW=:QOEANZIW:,QOEMWERT=:QOEMWERT:,QOESTDABW=:QOESTDABW:,QOEMINWERT=:QOEMINWERT:,QOEMAXWERT=:QOEMAXWERT:,QOENEUG=:QOENEUG:,QOENEOG=:QOENEOG:,QOETEXT1=:QOETEXT1:,QOETEXT2=:QOETEXT2:,QOEVKZ=:QOEVKZ:,QOEDRUCKKZ=:QOEDRUCKKZ:,QOEUGKZ=:QOEUGKZ:,QOEOGKZ=:QOEOGKZ:,QOECWEIGHT=:QOECWEIGHT:,QOEFPROCCOS=:QOEFPROCCOS:,QOEFPROCCOR=:QOEFPROCCOR:,QOEWE=:QOEWE:,QOEKOMMENT=:QOEKOMMENT:,QOEFILLER4=:QOEFILLER4:"
                        + " WHERE QOEMANDANT=:QOEMANDANT: AND QOEORDER=:QOEORDER: AND QOESTEP=:QOESTEP: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
                    break;
                default:
                    break;
            }  
            Connect2Proxy(or1);
        }
    }
}
